package com.css.dzj.zfjg.modules.taskinfo.controller;

import com.alibaba.fastjson.JSON;
import com.css.dzj.zfjg.common.audit.service.SysAuditService;
import com.css.dzj.zfjg.common.exception.CvaException;
import com.css.dzj.zfjg.common.util.*;
import com.css.dzj.zfjg.modules.admforce.entity.JgJgxwForceActionEntity;
import com.css.dzj.zfjg.modules.admforce.service.JgJgxwForceActionService;
import com.css.dzj.zfjg.modules.adminspection.entity.JgJgxwCheckActionEntity;
import com.css.dzj.zfjg.modules.adminspection.service.JgJgxwCheckActionService;
import com.css.dzj.zfjg.modules.admpunishment.entity.JgJgxwPunishActionEntity;
import com.css.dzj.zfjg.modules.admpunishment.service.JgJgxwPunishActionService;
import com.css.dzj.zfjg.modules.cohostrelate.entity.JgLhjgRwxbglbEntity;
import com.css.dzj.zfjg.modules.cohostrelate.service.JgLhjgRwxbglbService;
import com.css.dzj.zfjg.modules.complaintinfo.entity.JgLhjgComplaintInfoEntity;
import com.css.dzj.zfjg.modules.complaintinfo.service.JgLhjgComplaintInfoService;
import com.css.dzj.zfjg.modules.creditassess.entity.JgLhjgCreditAssessEntity;
import com.css.dzj.zfjg.modules.creditassess.service.CreditassessService;
import com.css.dzj.zfjg.modules.fb.entity.JgFbLhjgEntity;
import com.css.dzj.zfjg.modules.fb.service.JgFbLhjgService;
import com.css.dzj.zfjg.modules.feedback.entity.JgLhjgDffkEntity;
import com.css.dzj.zfjg.modules.feedback.service.JgLhjgDffkService;
import com.css.dzj.zfjg.modules.feedbackrelate.Controller.JgLhjgRwfkglController;
import com.css.dzj.zfjg.modules.feedbackrelate.entity.JgLhjgRwfkglEntity;
import com.css.dzj.zfjg.modules.jcdx.entity.JgLhjgJcdxEntity;
import com.css.dzj.zfjg.modules.jcdx.service.JgLhjgJcdxService;
import com.css.dzj.zfjg.modules.operatingabnormal.entity.JgLhjgOperatingAbnormalEntity;
import com.css.dzj.zfjg.modules.operatingabnormal.service.JgLhjgOperatingAbnormalService;
import com.css.dzj.zfjg.modules.other.entity.JgJgxwOtherActionEntity;
import com.css.dzj.zfjg.modules.other.service.JgJgxwOtherActionService;
import com.css.dzj.zfjg.modules.riskwarning.entity.JgLhjgRiskWarningEntity;
import com.css.dzj.zfjg.modules.riskwarning.service.JgLhjgRiskWarningService;
import com.css.dzj.zfjg.modules.seriouslllegal.entity.JgLhjgSeriousIllegalEntity;
import com.css.dzj.zfjg.modules.seriouslllegal.service.JgLhjgSeriousIllegalService;
import com.css.dzj.zfjg.modules.taskinfo.entity.JgLhjgRwsEntity;
import com.css.dzj.zfjg.modules.taskinfo.entity.rwblVo;
import com.css.dzj.zfjg.modules.taskinfo.service.JgLhjgRwsService;
import com.css.dzj.zfjg.modules.taskinfo.vo.RwjgLhfb;
import com.css.dzj.zfjg.modules.taskinfo.vo.RwsFqrVo;
import com.css.dzj.zfjg.modules.taskinfo.vo.RwsVo;
import com.css.dzj.zfjg.modules.taskinfo.vo.rwjgLh;
import com.css.dzj.zfjg.modules.tipinfo.entity.JgLhjgTipInfoEntity;
import com.css.dzj.zfjg.modules.tipinfo.service.JgLhjgTipInfoService;
import com.css.dzj.zfjg.sys.user.entity.LoginUser;
import com.querydsl.core.QueryResults;
import dm.jdbc.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * 联合监管任务办理
 */
@RestController
@RequestMapping(value = "/lhjgrwbl")
public class JgLhjgRwsController {

    @Autowired
    private JgLhjgRwsService jgLhjgRwsService;
    @Autowired
    private JgLhjgJcdxService jgLhjgJcdxService;
    @Autowired
    private JgLhjgDffkService jgLhjgDffkService;
    @Autowired
    private JgLhjgRwxbglbService jgLhjgRwxbglbService;
    //监管分办任务接口
    @Autowired
    private JgFbLhjgService fbLhjgService;
    @Autowired
    private ServiceUtil serviceUtil;
    @Autowired
    private JgLhjgRwfkglController jgLhjgRwfkglController;
    @Autowired
    private JgLhjgComplaintInfoService jgLhjgComplaintInfoService;
    @Autowired
    private CreditassessService creditassessService;
    @Autowired
    private JgLhjgOperatingAbnormalService abnormalService;
    @Autowired
    private JgLhjgTipInfoService jgLhjgTipInfoService;
    @Autowired
    private JgLhjgSeriousIllegalService jgLhjgSeriousIllegalService;
    @Autowired
    private JgLhjgRiskWarningService jgLhjgRiskWarningService;
    @Autowired
    private JgJgxwCheckActionService jgJgxwCheckActionService;
    @Autowired
    private JgJgxwForceActionService jgJgxwForceActionService;
    @Autowired
    private JgJgxwPunishActionService jgJgxwPunishActionService;
    @Autowired
    private JgJgxwOtherActionService jgJgxwOtherActionService;
    // base日志接口
    @Autowired
    SysAuditService sysAuditService;
    @Autowired
    HttpServletRequest request;

    /**
     * 列表
     * @author zch
     */
    @GetMapping("/list")
    public R list(@RequestParam Integer pageSize, @RequestParam Integer pageNo,
                  @RequestParam String taskname, @RequestParam String taskJgType,
                  @RequestParam String objectname, @RequestParam String fbBureau,
                  @RequestParam String fbDepartment,
                  @RequestParam(required = false) String createStartTime,
                  @RequestParam(required = false) String createEndTime,
                  @RequestParam(required = false) String receiveStartTime,
                  @RequestParam(required = false) String receiveEndTime,
                  @RequestParam String taskState){
        String s = "";
        try{
            PageRequest pageRequest = PageRequest.of(pageNo - 1, pageSize);
            taskname = taskname.replaceAll(" ", "");
            objectname = objectname.replaceAll(" ", "");
            fbBureau = fbBureau.replaceAll(" ", "");
            fbDepartment = fbDepartment.replaceAll(" ", "");
            QueryResults<RwjgLhfb> comResults = jgLhjgRwsService.queryPage(pageRequest,taskname,taskJgType,objectname,
                    fbBureau, fbDepartment,createStartTime,createEndTime,receiveStartTime,receiveEndTime,taskState);
            s = JSON.toJSONString(comResults);
            sysAuditService.saveSuccessAudit("任务分办分页查询成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_PAGE, s, request);
            return R.ok().put("data", comResults);
        }catch (Exception e){
            e.printStackTrace();
            sysAuditService.saveFailAudit("任务分办分页查询失败", Constant.ZFJG_LHJGRWBL, Constant.YZ, Constant.ZFJG_PAGE, s, e, request);
            return R.error(e.getMessage());
        }

    }

    /**
     * 信息
     * @author liyuan
     */
    @GetMapping("/info")
    public R info(@RequestParam String taskno){
        String s = "";
        try {
            //任务书表
            JgLhjgRwsEntity jgLhjgRws = jgLhjgRwsService.findNo(taskno);
            //发起单位类型
            String initiateUnitType = jgLhjgRws.getInitiateUnitType();
            if (!StringUtils.isEmpty(initiateUnitType) && "0".equals(initiateUnitType)) {
                jgLhjgRws.setInitiateUnitType("部门");
            }else if (!StringUtils.isEmpty(initiateUnitType) && "1".equals(initiateUnitType)){
                jgLhjgRws.setInitiateUnitType("地方");
            }
            //监管答复完善List
            List<JgLhjgDffkEntity> jgLhjgFkList = jgLhjgDffkService.getList(taskno);
            //协办关系表List
            List<JgLhjgRwxbglbEntity> jgLhjgXbList = jgLhjgRwsService.queryXBInfoById(taskno);
            //监管任务分办表
            JgFbLhjgEntity jgFbLhjgEntity = fbLhjgService.getByTaskno(taskno);
            JgLhjgJcdxEntity jcdxEntity = jgLhjgJcdxService.getById(taskno);


            //回显的大VO
            RwsVo rwsVo = new RwsVo();
            rwsVo.setJgLhjgRwsEntity(jgLhjgRws);
            rwsVo.setJgLhjgFkList(jgLhjgFkList);
            rwsVo.setJgLhjgRwxbglbList(jgLhjgXbList);
            rwsVo.setJgFbLhjgEntity(jgFbLhjgEntity);
            rwsVo.setJcdxEntity(jcdxEntity);
            s = JSON.toJSONString(rwsVo);
            sysAuditService.saveSuccessAudit("通过任务编码获取任务详情成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_SELECT, s, request);
            return R.ok().put("rwsVo", rwsVo);
        } catch (Exception e) {
            e.printStackTrace();
            sysAuditService.saveFailAudit("通过任务编码获取任务详情失败", Constant.ZFJG_LHJGRWBL, Constant.YZ, Constant.ZFJG_SELECT, s, e, request);
            return R.error(e.getMessage());
        }

    }


    /**
     * 分办任务
     *@author liyuan
     */
    @GetMapping("/fbtask")
    public R assignTask(@RequestParam String taskno,
                        @RequestParam String fbBureau,
                        @RequestParam String fbDepartment,
                        @RequestParam String fbType) {
        String s = "";
        try {
            jgLhjgRwsService.assignTask(taskno, fbBureau, fbDepartment,fbType);
            s = JSON.toJSONString(taskno);
            sysAuditService.saveSuccessAudit("任务分办成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_FBTASK, s, request);
        } catch (CvaException e) {
            e.printStackTrace();
            sysAuditService.saveFailAudit("任务分办失败", Constant.ZFJG_LHJGRWBL, Constant.YZ, Constant.ZFJG_FBTASK, s, e, request);
            return R.error("分办失败!");
        }
        return R.ok();
    }


    /**
     * 发起人获取列表
     *@author liyuan
     */
    @GetMapping("/fqrList")
    public R fqList(@RequestParam("taskname") String taskname,
                    @RequestParam("taskJgtype") String taskJgtype,
                    @RequestParam("objectName") String objectName,
                    @RequestParam("launchBureau") String launchBureau,
                    @RequestParam("launchState") String launchState,
                    @RequestParam("initiateunitno") String initiateunitno,
                    @RequestParam(required = false) String taskStartTimeFirst,
                    @RequestParam(required = false) String taskStartTimeSecond,
                    @RequestParam Integer pageSize, @RequestParam Integer pageNo) {
        String s = "";
        try {
            PageRequest pageRequest = PageRequest.of(pageNo - 1, pageSize);
            QueryResults<RwsFqrVo> page = jgLhjgRwsService.queryFqTaskPage(taskname,taskJgtype,objectName,launchBureau,launchState,
                    initiateunitno,taskStartTimeFirst, taskStartTimeSecond, pageRequest);
            s = JSON.toJSONString(page);
            sysAuditService.saveSuccessAudit("任务发起分页查询成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_PAGE, s, request);
            return R.ok().put("page", page);
        } catch (Exception e) {
            e.printStackTrace();
            sysAuditService.saveFailAudit("任务发起分页查询失败", Constant.ZFJG_LHJGRWBL, Constant.YZ, Constant.ZFJG_PAGE, s, e, request);
            return R.error(e.getMessage());
        }

    }

    /**
     * 发起任务
     *@author liyuan
     */
    @GetMapping("/launch")
    public R launch(@RequestParam("taskno") String taskno){
        String s = "";
        try {
            jgLhjgRwsService.launch(taskno);
            s = JSON.toJSONString(taskno);
            sysAuditService.saveSuccessAudit("联合监管任务发起成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_LAUNCH, s, request);
        }catch (CvaException e){
            e.printStackTrace();
            sysAuditService.saveFailAudit("联合监管任务发起失败", Constant.ZFJG_LHJGRWBL, Constant.YZ, Constant.ZFJG_LAUNCH, s, e, request);
            return R.error("发起任务失败！");
        }
        return R.ok();
    }

    /**
     * 根据taskno查询任务书信息
     */
    @GetMapping("/tainfo")
    public R tainfo(@RequestParam String taskno){
        String s = "";
        try {
            JgLhjgRwsEntity taskEntity = jgLhjgRwsService.findNo(taskno);
            s =JSON.toJSONString(taskEntity);
            sysAuditService.saveSuccessAudit("通过任务编码获取任务单表信息成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_SELECT, s, request);
            return R.ok().put("taskEntity", taskEntity);
        } catch (Exception e) {
            e.printStackTrace();
            sysAuditService.saveFailAudit("通过任务编码获取任务单表信息失败", Constant.ZFJG_LHJGRWBL, Constant.YZ, Constant.ZFJG_SELECT, s, e, request);
            return R.error(e.getMessage());
        }

    }
    @RequestMapping("/save")
    /**新增
     *@author zch
     *@description TODO
     *@date  2020/02/22
     *@param
     *@return com.css.common.utils.R
     */
    public R save(@RequestBody rwjgLh rwjgLh, HttpServletRequest request) {
        String s ="";
        try{
            //接收JgLhjgRwsEntity对象
            JgLhjgRwsEntity jgLhjgRws = rwjgLh.getJgLhjgRwsEntity();

            //接收JgLhjgRwxbglbEntity对象list

            List<JgLhjgRwxbglbEntity> jgLhjgRwxbglbEntityList = new ArrayList<>();
            jgLhjgRwxbglbEntityList=rwjgLh.getJgLhjgRwxbglbEntityList();
            String unionSectionName="";
            if (jgLhjgRwxbglbEntityList != null && jgLhjgRwxbglbEntityList.size()>0){
                for (JgLhjgRwxbglbEntity jgLhjgRwxbglbEntity :jgLhjgRwxbglbEntityList){
                    unionSectionName=unionSectionName +"," + jgLhjgRwxbglbEntity.getUnionName();
                }
                unionSectionName=unionSectionName.substring(1,unionSectionName.length());
            }else{
                return R.error("协办部门不能为空！");
            }
            jgLhjgRws.setUnionSectionName(unionSectionName);
            //接收JgLhjgJcdxEntity对象

            JgLhjgJcdxEntity jgLhjgJcdxEntity = rwjgLh.getJgLhjgJcdxEntity();
          //  jgLhjgJcdxEntity.setObjectMark(jgLhjgJcdxEntity.getEnterprisecreditcode());

            //处理监管类型
           /* String jgType = jgLhjgRws.getTaskJgType();
            if (jgType != null && !"".equals(jgType)){
                jgType = jgType.replace("[","");
                jgType = jgType.replace("]","");
                jgType = jgType.replace("\"行政检查\"","1");
                jgType = jgType.replace("\"行政处罚\"","2");
                jgType = jgType.replace("\"行政强制\"","3");
                jgType = jgType.replace("\"其他\"","4");
            }
            jgLhjgRws.setTaskJgType(jgType);*/
            String superviseobjectno = jgLhjgRws.getSuperviseobjectno();

            //taskno
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
            SimpleDateFormat sdfNo = new SimpleDateFormat("yyyyMMdd");
            Date date = new Date();
            String timeNo = "";
            timeNo = sdfNo.format(date.getTime());
            //获取当前所有的发起任务的最大的任务编码
            String maxTaskno =jgLhjgRwsService.getMaxOne();
            String lastNo = "";
            if (maxTaskno != "" && maxTaskno != null){
                Integer num = Integer.valueOf(maxTaskno) ;
                lastNo = String.valueOf(num + 1);
                if (lastNo.length() == 1){
                    lastNo = "00" + lastNo;
                }else if (lastNo.length() == 2){
                    lastNo = "0" + lastNo;
                }
            }else {
                lastNo = "001";
            }

            //获取发起单位类型  0：部门 1：地方
            String initiateUnitType = jgLhjgRws.getInitiateUnitType();

            //发起单位是地方时，获取当前用户,通过用户获取其司局名称和司局编码
            R r = serviceUtil.getUserInfoByRequest(request);
            LoginUser userInfo=new LoginUser();
            if(r.getCode().equals("200")) {
                 userInfo =  (LoginUser)r.get("data");
            }
            String departmentName = userInfo.getOrgName();
            String name = departmentName.substring(0,2);
            String taskno = "";
            if ("0".equals(initiateUnitType)){
                taskno = "LHJG000007" + timeNo + "B" +lastNo;
            }else {
                taskno = "LHJG000007" + timeNo + "A" +lastNo;
                //调接口获取地方管局所在地的行政区划编码
            /*    String launchBureau = jgLhjgRws.getLaunchBureau();
                String areaName = "";
                if (launchBureau != null && !"".equals(launchBureau)) {
                    String launchBureauStr = dictonaryUtil.getLaunchBureau(launchBureau);
                    if (org.apache.commons.lang.StringUtils.isNotEmpty(launchBureauStr)) {
                        areaName = launchBureauStr;
                    }
                }
                if (StringUtil.isNotEmpty(areaName)){
                    areaName = areaName.substring(0,2);
                }
                String deptNo = areaUtils.getCodeByName(areaName);
                taskno = "LHJG" + deptNo + timeNo + "A" + lastNo;*/
            }
            jgLhjgRws.setTaskno(taskno);


            jgLhjgRws.setCreateTime(new Date(date.getTime()));
            jgLhjgRws.setCreateUser(userInfo.getLoginName());
            jgLhjgRws.setTaskType("1");
            jgLhjgRws.setLaunchState(CvaConstants.NEW_TASK_UN_LANUCH);
            jgLhjgRws.setDelFlag(CvaConstants.UN_DEL_FLAG);
            JgJgxwCheckActionEntity jgJgxwCheckActionEntity = rwjgLh.getJgJgxwCheckActionEntity();
            JgJgxwPunishActionEntity jgJgxwPunishActionEntity = rwjgLh.getJgJgxwPunishActionEntity();
            JgJgxwForceActionEntity jgJgxwForceActionEntity = rwjgLh.getJgJgxwForceActionEntity();
            JgJgxwOtherActionEntity jgJgxwOtherActionEntity = rwjgLh.getJgJgxwOtherActionEntity();
            jgLhjgRwsService.create(jgLhjgRws,jgLhjgJcdxEntity,jgLhjgRwxbglbEntityList,jgJgxwCheckActionEntity,jgJgxwPunishActionEntity,jgJgxwForceActionEntity,jgJgxwOtherActionEntity);
            s = JSON.toJSONString(jgLhjgRws);
            sysAuditService.saveSuccessAudit("联合监管发起新建任务成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_ADD, s, request);
        }catch (CvaException e){
            e.printStackTrace();
            sysAuditService.saveFailAudit("联合监管发起新建任务失败", Constant.ZFJG_LHJGRWBL, Constant.YZ, Constant.ZFJG_ADD, s, e, request);
            return R.error("新建失败");
        }
        return R.ok();
    }

    @RequestMapping("/update")
    /**修改
     *@author zch
     *@date  2019/12/22
     *@param
     *@return com.css.common.utils.R
     */
    public R update(@RequestBody rwjgLh rwjgLh, HttpServletRequest request){
        String s = "";
        try {

            JgLhjgRwsEntity jgLhjgRws = rwjgLh.getJgLhjgRwsEntity();
            R r = serviceUtil.getUserInfoByRequest(request);
            LoginUser userInfo=new LoginUser();
            if(r.getCode().equals("200")) {
                userInfo =  (LoginUser)r.get("data");
            }
            jgLhjgRws.setUpdateUser(userInfo.getLoginName());
            Date date = new Date();
            jgLhjgRws.setUpdateTime(new Date());
            //处理监管类型
          /*  String jgType = jgLhjgRws.getTaskJgType();
            if (jgType != null && !"".equals(jgType)){
                jgType = jgType.replace("[","");
                jgType = jgType.replace("]","");
                jgType = jgType.replace("\"行政检查\"","1");
                jgType = jgType.replace("\"行政处罚\"","2");
                jgType = jgType.replace("\"行政强制\"","3");
                jgType = jgType.replace("\"其他\"","4");
            }
            jgLhjgRws.setTaskJgType(jgType);*/
          //修改任务书表
            JgLhjgRwsEntity oldjgLhjgRwsEntity = jgLhjgRwsService.findById(jgLhjgRws.getTaskId());
            BeanUtil.copyBeanNotEmptyToBean(jgLhjgRws, oldjgLhjgRwsEntity);



            //接收JgLhjgRwxbglbEntity对象list
            List<JgLhjgRwxbglbEntity> jgLhjgRwxbglbEntityList = new ArrayList<>();
            jgLhjgRwxbglbEntityList=rwjgLh.getJgLhjgRwxbglbEntityList();
            String unionSectionName="";
            if (jgLhjgRwxbglbEntityList != null && jgLhjgRwxbglbEntityList.size()>0){
                for (JgLhjgRwxbglbEntity jgLhjgRwxbglbEntity :jgLhjgRwxbglbEntityList){
                    unionSectionName=unionSectionName +"," + jgLhjgRwxbglbEntity.getUnionName();
                }
                unionSectionName=unionSectionName.substring(1,unionSectionName.length());
            }else{
                return R.error("协办部门不能为空！");
            }
            jgLhjgRws.setUnionSectionName(unionSectionName);

            JgJgxwCheckActionEntity jgJgxwCheckActionEntity = rwjgLh.getJgJgxwCheckActionEntity();
            JgJgxwPunishActionEntity jgJgxwPunishActionEntity = rwjgLh.getJgJgxwPunishActionEntity();
            JgJgxwForceActionEntity jgJgxwForceActionEntity = rwjgLh.getJgJgxwForceActionEntity();
            JgJgxwOtherActionEntity jgJgxwOtherActionEntity = rwjgLh.getJgJgxwOtherActionEntity();
            //接收JgLhjgJcdxEntity对象
            JgLhjgJcdxEntity jgLhjgJcdxEntity = rwjgLh.getJgLhjgJcdxEntity();
            jgLhjgRwsService.updateRwsAndall(jgLhjgRws, jgLhjgJcdxEntity, jgLhjgRwxbglbEntityList,jgJgxwCheckActionEntity,jgJgxwPunishActionEntity,jgJgxwForceActionEntity,jgJgxwOtherActionEntity);
            s = JSON.toJSONString(jgLhjgRws);
            sysAuditService.saveSuccessAudit("联合监管发起修改任务成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_UPDATE, s, request);
        }catch (CvaException e){
            e.printStackTrace();
            sysAuditService.saveFailAudit("联合监管发起修改任务失败", Constant.ZFJG_LHJGRWBL, Constant.YZ, Constant.ZFJG_UPDATE, s, e, request);
            return R.error("修改失败！");
        }
        return R.ok();
    }


    /**
     * 删除
     */
    @PostMapping("/delete")
    public R delete(@RequestParam String taskId){
        String s = "";
        try {
            if(jgLhjgRwsService.delete(taskId)){
                s = JSON.toJSONString(taskId);
                sysAuditService.saveSuccessAudit("联合监管任务删除成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_DELETE, s, request);
                return R.ok("操作成功!");
            }else{
                return  R.error("操作失败!");
            }
        } catch(Exception e) {
            e.printStackTrace();
            sysAuditService.saveFailAudit("联合监管任务删除失败", Constant.ZFJG_LHJGRWBL, Constant.YZ, Constant.ZFJG_DELETE, s, e, request);
            return R.error(e.getMessage());
        }
    }

    /**
     * 联合监管任务办理接收任务
     */
    @PostMapping("/receive")
    public R receive(@RequestParam String taskno){
        String s = "";
        //1.修改任务表的状态为 处理中，修改分办表达的状态为 已处理
        try {
            if(StringUtils.isEmpty(taskno)){
                return R.error("参数为空！");
            }
            JgLhjgRwsEntity jgLhjgRwsEntity =  jgLhjgRwsService.findNo(taskno);
            JgFbLhjgEntity   fbLhjgEntity   =  fbLhjgService.getByTaskno(taskno);
            //处理中
            jgLhjgRwsEntity.setTaskState("103");
            jgLhjgRwsService.update(jgLhjgRwsEntity);

            //已处理
            fbLhjgEntity.setFbState("202");
            //受理时间
            SimpleDateFormat spf = new SimpleDateFormat("yyyy-MM-dd");
            String formatDate  = spf.format(new Date());
            try{
                Date evaluationDate = spf.parse(formatDate);
                fbLhjgEntity.setReceiveTime(evaluationDate);
            }catch (Exception e){
                e.printStackTrace();
            }

            fbLhjgService.update(fbLhjgEntity);
            s = JSON.toJSONString(fbLhjgEntity);
            sysAuditService.saveSuccessAudit("联合监管办理接收任务成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_RECEIVE, s, request);
        }catch (CvaException e){
            e.printStackTrace();
            sysAuditService.saveFailAudit("联合监管办理接收任务失败", Constant.ZFJG_LHJGRWBL, Constant.YZ, Constant.ZFJG_RECEIVE, s, e, request);
            return R.error("接收失败！");
        }
        return R.ok();
    }

    /**
     * 联合监管任务办理拒绝任务
     */
    @PostMapping("/refuse")
    public R refuse(@RequestParam String taskno,@RequestParam String refuseReason){
        //1.修改任务表的状态为 已拒绝，修改分办表达的状态为 已拒绝
        String s = "";
        try {
            if(StringUtils.isEmpty(taskno)){
                return R.error("参数为空！");
            }
            JgLhjgRwsEntity jgLhjgRwsEntity =  jgLhjgRwsService.findNo(taskno);
            JgFbLhjgEntity   fbLhjgEntity   =  fbLhjgService.getByTaskno(taskno);
            //已拒绝
            jgLhjgRwsEntity.setTaskState("106");
            jgLhjgRwsService.update(jgLhjgRwsEntity);

            //已拒绝
            fbLhjgEntity.setFbState("202");
            fbLhjgEntity.setRefuseTime(new Date());
            fbLhjgEntity.setRefuseReason(refuseReason);
            fbLhjgService.update(fbLhjgEntity);
            s = JSON.toJSONString(fbLhjgEntity);
            sysAuditService.saveSuccessAudit("联合监管办理任务拒绝成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_REFUSE, s, request);
        }catch (CvaException e){
            e.printStackTrace();
            sysAuditService.saveFailAudit("联合监管办理任务拒绝失败", Constant.ZFJG_LHJGRWBL, Constant.YZ, Constant.ZFJG_REFUSE, s, e, request);
            return R.error("操作失败！");
        }
        return R.ok();
    }

    /**答复提交
     *@author lky
     *@description TODO
     *@date   2020/02/22
     *@param
     *@return com.css.common.utils.R
     */
    @RequestMapping("/reply")
    public R reply(@RequestBody rwjgLh rwjgLh, HttpServletRequest request){
        String s = "";
        try {
            JgLhjgDffkEntity jgLhjgDffkEntity = rwjgLh.getJgLhjgDffkEntity();
            JgJgxwCheckActionEntity jgJgxwCheckActionEntity = rwjgLh.getJgJgxwCheckActionEntity();
            JgJgxwPunishActionEntity jgJgxwPunishActionEntity = rwjgLh.getJgJgxwPunishActionEntity();
            JgJgxwForceActionEntity jgJgxwForceActionEntity = rwjgLh.getJgJgxwForceActionEntity();
            JgJgxwOtherActionEntity jgJgxwOtherActionEntity = rwjgLh.getJgJgxwOtherActionEntity();
            jgLhjgRwsService.reply(jgLhjgDffkEntity,jgJgxwCheckActionEntity,jgJgxwPunishActionEntity,
                    jgJgxwForceActionEntity,jgJgxwOtherActionEntity,request);
            s = JSON.toJSONString(jgLhjgDffkEntity);
            sysAuditService.saveSuccessAudit("联合监管任务办理任务答复成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_REPLY, s, request);
        } catch (Exception e) {
            e.printStackTrace();
            sysAuditService.saveFailAudit("联合监管任务办理任务答复失败", Constant.ZFJG_LHJGRWBL, Constant.YZ, Constant.ZFJG_REPLY, s, e, request);
            return R.error("操作失败!");
        }
        return R.ok();
    }

    /**
     * 办理人监管任务列表
     * @author wt
     * @date 2020\2\21 0021
     */
    @GetMapping("/blrList")
    public R getBlrList(@RequestParam String taskname,
                        @RequestParam String taskJgType,
                        @RequestParam String fbStartTime,
                        @RequestParam String fbEndTime,
                        @RequestParam String objectname,
                        @RequestParam String taskState,
                        @RequestParam Integer pageSize, @RequestParam Integer pageNo,
                        HttpServletRequest request) {
        String s ="";
        try{
            PageRequest pageRequest = PageRequest.of(pageNo - 1, pageSize);
            String orgName = ServiceUtil.getOrgName(request);
            if(StringUtils.isEmpty(orgName)) {
                return R.error("登录人所属机构不能为空");
            }
            QueryResults<rwblVo> blrResults = jgLhjgRwsService.getBlrList(orgName, taskname,taskJgType,fbStartTime,fbEndTime,objectname,taskState,pageRequest);
            s = JSON.toJSONString(blrResults);
            sysAuditService.saveSuccessAudit("联合监管办理分页查询成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_PAGE, s, request);
            return R.ok().put("data", blrResults);
        }catch (Exception e){
            e.printStackTrace();
            sysAuditService.saveFailAudit("联合监管办理分页查询失败", Constant.ZFJG_LHJGRWBL, Constant.YZ, Constant.ZFJG_PAGE, s, e, request);
            return R.error(e.getMessage());
        }
    }
    /**
     *@author lky
     *@description TODO
     *@date  2020/02/22
     *@param
     *@return com.css.common.utils.R
     * 修改反馈状态
     */
    @GetMapping("/feedback")
    public R feedBack(@RequestParam String taskno){
        String s = "";
        try {
            jgLhjgRwsService.feedBack(taskno);
            s =JSON.toJSONString(taskno);
            sysAuditService.saveSuccessAudit("联合监管任务反馈成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_FEEDBACK, s, request);
        }catch(CvaException e){
            e.printStackTrace();
            sysAuditService.saveFailAudit("联合监管任务反馈失败", Constant.ZFJG_LHJGRWBL, Constant.YZ, Constant.ZFJG_FEEDBACK, s, e, request);
            return R.error(e.getMessage());
        }
        return R.ok();
    }

    /**
     *@author lky
     *@description TODO
     *@date  2020/02/22
     *@param
     *@return com.css.common.utils.R
     * 修改结束状态
     */
    @GetMapping("/end")
    public R end(@RequestParam String taskno){
        String s = "";
        try {
            jgLhjgRwsService.end(taskno);
            s = JSON.toJSONString(taskno);
            sysAuditService.saveSuccessAudit("联合监管任务结束成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_ENDTASK, s, request);
        }catch(CvaException e){
            e.printStackTrace();
            sysAuditService.saveFailAudit("联合监管任务结束失败", Constant.ZFJG_LHJGRWBL, Constant.YZ, Constant.ZFJG_ENDTASK, s, e, request);
            return R.error(e.getMessage());
        }
        return R.ok();
    }
    /**
     * 根据任务编码查询企业信息
     * author xgdou
     * date 2020/02/23
     */
    @GetMapping("/findByTaskNo")
    public R findByTaskNo(@RequestParam String taskNo) {
        String s = "";
        try {
            JgLhjgComplaintInfoEntity complaintInfo = jgLhjgComplaintInfoService.findByTaskNo(taskNo);
            JgLhjgCreditAssessEntity creditAssessEntity = creditassessService.findByTaskNo(taskNo);
            JgLhjgOperatingAbnormalEntity abnormalEntity = abnormalService.findByTaskNo(taskNo);
            JgLhjgTipInfoEntity tipInfoEntity = jgLhjgTipInfoService.findByTaskNo(taskNo);
            JgLhjgSeriousIllegalEntity seriousIllegalEntity = jgLhjgSeriousIllegalService.findByTaskNo(taskNo);
            JgLhjgRiskWarningEntity jgLhjgRiskWarningEntity = jgLhjgRiskWarningService.findByTaskNo(taskNo);
            //回显的大VO
            rwjgLh rwjgLhVo = new rwjgLh();
            //企业投诉信息
            rwjgLhVo.setJgLhjgComplaintInfoEntity(complaintInfo);
            //企业信用评估信息
            rwjgLhVo.setJgLhjgCreditAssessEntity(creditAssessEntity);
            //企业经营异常名录信息
            rwjgLhVo.setJgLhjgOperatingAbnormalEntity(abnormalEntity);
            //企业举报信息
            rwjgLhVo.setJgLhjgTipInfoEntity(tipInfoEntity);
            //企业严重违法信息
            rwjgLhVo.setJgLhjgSeriousIllegalEntity(seriousIllegalEntity);
            //企业风险预警信息
            rwjgLhVo.setJgLhjgRiskWarningEntity(jgLhjgRiskWarningEntity);
            s =JSON.toJSONString(rwjgLhVo);
            sysAuditService.saveSuccessAudit("通过任务编码获取企业信息成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_SELECT, s, request);
            return R.ok().put("rwjgLhVo", rwjgLhVo);
        } catch (Exception e) {
            e.printStackTrace();
            sysAuditService.saveFailAudit("通过任务编码获取企业信息失败", Constant.ZFJG_LHJGRWBL, Constant.YZ, Constant.ZFJG_SELECT, s, e, request);
            return R.error(e.getMessage());
        }


    }


    @GetMapping("/findOneByCode")
    /**
     *@author xgdou
     *@description TODO
     *@date  20/02/23
     *@param taskno,superviseItemCode
     *@return com.css.common.utils.R
     * 根据编码查询行为信息
     */
    public R findOneByCode(@RequestParam String taskNo,
                           @RequestParam String superviseItemCode) {
        String s = "";
        try {
            List<JgLhjgRwfkglEntity> lhjgRwfkglEntities = jgLhjgRwfkglController.findListByTaskNo(taskNo, superviseItemCode);
            for (JgLhjgRwfkglEntity lhjgRwfkglEntity : lhjgRwfkglEntities) {
                String actionId = lhjgRwfkglEntity.getActionId();
                //回显的大VO
                rwjgLh rwjgLhVo2 = new rwjgLh();
                if (superviseItemCode.equals("1")) {
                    rwjgLh jgxwCheckActionVo = jgJgxwCheckActionService.findOneById(actionId);
                    s = JSON.toJSONString(jgxwCheckActionVo);
                    sysAuditService.saveSuccessAudit("通过任务编码获取检查行为信息成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_SELECT, s, request);
                    return R.ok().put("rwjgLhVo2", jgxwCheckActionVo);
                } else if (superviseItemCode.equals("3")) {
                    rwjgLh forceActionVo = jgJgxwForceActionService.findOneById(actionId);
                    s = JSON.toJSONString(forceActionVo);
                    sysAuditService.saveSuccessAudit("通过任务编码获取行政强制行为成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_SELECT, s, request);
                    return R.ok().put("rwjgLhVo2", forceActionVo);
                } else if (superviseItemCode.equals("2")) {
                    rwjgLh punishActionVo = jgJgxwPunishActionService.findOneById(actionId);
                    s = JSON.toJSONString(punishActionVo);
                    sysAuditService.saveSuccessAudit("通过任务编码获取行政处罚行为成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_SELECT, s, request);
                    return R.ok().put("rwjgLhVo2", punishActionVo);
                } else if (superviseItemCode.equals("4")) {
                    rwjgLh otherActionVo = jgJgxwOtherActionService.findOneById(actionId);
                    sysAuditService.saveSuccessAudit("通过任务编码获取行政其他行为成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_SELECT, s, request);
                    s = JSON.toJSONString(otherActionVo);
                    return R.ok().put("rwjgLhVo2", otherActionVo);
                }
            }
            return R.ok().put("rwjgLhVo2", "");
        }catch (Exception e){
            e.printStackTrace();
            sysAuditService.saveFailAudit("通过任务编码获取信息失败", Constant.ZFJG_LHJGRWBL, Constant.YZ, Constant.ZFJG_SELECT, s, e, request);
            return R.error(e.getMessage());
        }
    }

    @PostMapping("/fqTaskInfo")
    /**获取单个发起任务
     *@author xgdou
     *@description TODO
     *@date  2020/02/23
     *@param [paramsMap]
     *@return com.css.common.utils.R
     */
    public R getInfo(@RequestParam String taskno){
        String s = "";
        try{
            JgLhjgRwsEntity jgLhjgRws = jgLhjgRwsService.queryInfoById(taskno);
        /*String taskJgType = jgLhjgRws.getTaskJgType();
        String jglxSplit = "";
        if (taskJgType != null && !"".equals(taskJgType)) {
            String[] strs = taskJgType.split(",");
            for (int a = 0; a < strs.length; a++) {
                String jglxStr = strs[a];
                jglxSplit += jglxStr + ",";
            }
            jglxSplit = jglxSplit.substring(0, jglxSplit.length() - 1);
            jgLhjgRws.setTaskJgType(jglxSplit);
        }*/

            //证件类型

            JgLhjgJcdxEntity jgLhjgJcdxEntity = jgLhjgJcdxService.getById(taskno);
        /*if (jgLhjgJcdxEntity != null) {
            String certificateType = jgLhjgJcdxEntity.getCertificateType();
            if (certificateType != null && !"".equals(certificateType)) {
                String certificateTypeStr = certificateType;
                if (org.apache.commons.lang.StringUtils.isNotEmpty(certificateTypeStr)) {
                    jgLhjgJcdxEntity.setCertificateType(certificateTypeStr);
                }
            }
        }*/

            //发起单位类型
            String initiateUnitType = jgLhjgRws.getInitiateUnitType();
            if (StringUtil.isNotEmpty(initiateUnitType) && "0".equals(initiateUnitType)) {
                jgLhjgRws.setInitiateUnitType("部门");
            }else if (StringUtil.isNotEmpty(initiateUnitType) && "1".equals(initiateUnitType)){
                jgLhjgRws.setInitiateUnitType("地方");
            }
            //查四级后拼起来放入superviseobjectno
        /*String superviseobjectno = jgLhjgRws.getSuperviseobjectno();
        List<String> supNames = new ArrayList<>();
        if (superviseobjectno != null && !"".equals(superviseobjectno)) {
            String[] strs = superviseobjectno.split(",");
            for (int a = 0; a < strs.length; a++) {
                String[] sups = strs[a].split("-");
                String superviseobjectnoNew = "";
                for (int s = 0; s < sups.length; s++) {
                    if (s == 0) {
                        superviseobjectnoNew = superviseobjectnoNew + sups[s];
                    } else {
                        superviseobjectnoNew = superviseobjectnoNew + sups[s];
                    }
                }
                if (StringUtil.isNotEmpty(superviseobjectnoNew)) {
                    superviseobjectnoNew = superviseobjectnoNew.substring(0, superviseobjectnoNew.length() - 1);
                }
                supNames.add(superviseobjectnoNew);
            }
            if(supNames != null && supNames.size()>0) {
                System.out.println(supNames.toString());
                jgLhjgRws.setSuperviseobjectno(supNames.toString().replace("[","").replace("]",""));
            }
        }*/

            List<JgLhjgDffkEntity> jgLhjgDffkEntityList = jgLhjgDffkService.getList(taskno);
            List<JgLhjgRwxbglbEntity> jgLhjgRwxbglbEntityList = jgLhjgRwxbglbService.getListbyTaskno(taskno);

            //回显大的vo
            rwjgLh rwjgLhVo3 = new rwjgLh();

            // 获取四个行为信息
            List<JgLhjgRwfkglEntity> checkfkglEntities = jgLhjgRwfkglController.findListByTaskNo(taskno, "1");
            if(checkfkglEntities != null && checkfkglEntities.size() > 0) {
                for (JgLhjgRwfkglEntity lhjgRwfkglEntity : checkfkglEntities) {
                    if(!StringUtils.isEmpty(lhjgRwfkglEntity.getActionId())) {
                        rwjgLh jgxwCheckActionVo = jgJgxwCheckActionService.findOneById(lhjgRwfkglEntity.getActionId());
                        if(jgxwCheckActionVo != null) {
                            rwjgLhVo3.setJgJgxwCheckActionEntity(jgxwCheckActionVo.getJgJgxwCheckActionEntity());
                        }
                    }
                }
            }


            List<JgLhjgRwfkglEntity> punishfkglEntities = jgLhjgRwfkglController.findListByTaskNo(taskno, "2");
            if(punishfkglEntities != null && punishfkglEntities.size() > 0) {
                for (JgLhjgRwfkglEntity lhjgRwfkglEntity : punishfkglEntities) {
                    if(!StringUtils.isEmpty(lhjgRwfkglEntity.getActionId())) {
                        rwjgLh jgxwPunishActionVo = jgJgxwPunishActionService.findOneById(lhjgRwfkglEntity.getActionId());
                        if(jgxwPunishActionVo != null) {
                            rwjgLhVo3.setJgJgxwPunishActionEntity(jgxwPunishActionVo.getJgJgxwPunishActionEntity());
                        }
                    }
                }
            }

            List<JgLhjgRwfkglEntity> forcefkglEntites = jgLhjgRwfkglController.findListByTaskNo(taskno, "3");
            if(forcefkglEntites != null && forcefkglEntites.size() > 0) {
                for (JgLhjgRwfkglEntity lhjgRwfkglEntity : forcefkglEntites) {
                    if(!StringUtils.isEmpty(lhjgRwfkglEntity.getActionId())) {
                        rwjgLh jgxwForceActionVo = jgJgxwForceActionService.findOneById(lhjgRwfkglEntity.getActionId());
                        if(jgxwForceActionVo != null) {
                            rwjgLhVo3.setJgJgxwForceActionEntity(jgxwForceActionVo.getJgJgxwForceActionEntity());
                        }
                    }
                }
            }


            List<JgLhjgRwfkglEntity> otherfkglEntites = jgLhjgRwfkglController.findListByTaskNo(taskno, "4");
            if(otherfkglEntites != null && otherfkglEntites.size() > 0) {
                for (JgLhjgRwfkglEntity lhjgRwfkglEntity : otherfkglEntites) {
                    if(!StringUtils.isEmpty(lhjgRwfkglEntity.getActionId())) {
                        rwjgLh jgxwOtherActionVo = jgJgxwOtherActionService.findOneById(lhjgRwfkglEntity.getActionId());
                        if(jgxwOtherActionVo != null) {
                            rwjgLhVo3.setJgJgxwOtherActionEntity(jgxwOtherActionVo.getJgJgxwOtherActionEntity());
                        }
                    }
                }
            }


            //任务表
            rwjgLhVo3.setJgLhjgRwsEntity(jgLhjgRws);
            //检查对象表
            rwjgLhVo3.setJgLhjgJcdxEntity(jgLhjgJcdxEntity);
            //答复表
            rwjgLhVo3.setJgLhjgDffkEntityList(jgLhjgDffkEntityList);
            //协办关系表
            rwjgLhVo3.setJgLhjgRwxbglbEntityList(jgLhjgRwxbglbEntityList);
            /*rwjgLhVo3.setSuperviseobjectName(jgLhjgRws.getSuperviseobjectno());*/
            s =JSON.toJSONString(rwjgLhVo3);
            sysAuditService.saveSuccessAudit("通过任务编码获取单个发起任务成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_SELECT, s, request);
            return R.ok().put("rwjgLhVo3", rwjgLhVo3);
        } catch (Exception e) {
            e.printStackTrace();
            sysAuditService.saveFailAudit("通过任务编码获取单个发起任务失败", Constant.ZFJG_LHJGRWBL, Constant.YZ, Constant.ZFJG_SELECT, s, e, request);
            return R.error(e.getMessage());
        }

    }
    @GetMapping("/findOneByCodeAndUuid")
    /**
     *@author zch
     *@description TODO
     *@date  20/02/25
     *@param taskno,superviseItemCode,
     *@return com.css.common.utils.R
     * 根据反馈ID和编码查询行为信息
     */
    public R findOneByCodeAndUuid(@RequestParam String taskNo,
                                  @RequestParam String superviseItemCode,@RequestParam String uuid) {
        JgLhjgRwfkglEntity lhjgRwfkglEntity = jgLhjgRwfkglController.findOneByTaskNo(taskNo,superviseItemCode,uuid);

        String actionId = lhjgRwfkglEntity.getActionId();
        //回显的大VO
        rwjgLh rwjgLhVo2 = new rwjgLh();
        String s = "";
        if (superviseItemCode.equals("1")) {
            rwjgLh jgxwCheckActionVo = jgJgxwCheckActionService.findOneById(actionId);
            sysAuditService.saveSuccessAudit("通过任务编码和反馈id获取行政检查行为信息成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_SELECT, s, request);
            return R.ok().put("rwjgLhVo2", jgxwCheckActionVo);
        } else if (superviseItemCode.equals("3")) {
            rwjgLh forceActionVo = jgJgxwForceActionService.findOneById(actionId);
            sysAuditService.saveSuccessAudit("通过任务编码和反馈id获取行政强制行为信息成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_SELECT, s, request);
            return R.ok().put("rwjgLhVo2", forceActionVo);

        } else if (superviseItemCode.equals("2")) {
            rwjgLh punishActionVo = jgJgxwPunishActionService.findOneById(actionId);
            sysAuditService.saveSuccessAudit("通过任务编码和反馈id获取行政处罚行为信息成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_SELECT, s, request);
            return R.ok().put("rwjgLhVo2", punishActionVo);
        } else if (superviseItemCode.equals("4")) {
            sysAuditService.saveSuccessAudit("通过任务编码和反馈id获取行政其它行为信息成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_SELECT, s, request);
            rwjgLh otherActionVo = jgJgxwOtherActionService.findOneById(actionId);
            return R.ok().put("rwjgLhVo2", otherActionVo);
        }
        return R.ok().put("rwjgLhVo2", "");
    }

    /**
     * 分页查询所有认领超时提醒的任务
     * @param pageSize
     * @param pageNo
     * @return
     */
    @GetMapping("/queryOvertime")
    public R queryOvertime(@RequestParam Integer pageSize, @RequestParam Integer pageNo) {
        String s = "";
        try {
            PageRequest pageRequest = PageRequest.of(pageNo - 1, pageSize);
            QueryResults<JgLhjgRwsEntity> results = jgLhjgRwsService.queryOvertime(pageRequest);
            s =JSON.toJSONString(results);
            sysAuditService.saveSuccessAudit("分页查询认领超时提醒任务成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_PAGE, s, request);
            return R.ok().put("data", results);
        } catch(Exception e) {
            e.printStackTrace();
            sysAuditService.saveFailAudit("分页查询认领超时提醒任务失败", Constant.ZFJG_MODULE_FEEDBACK, Constant.YZ, Constant.ZFJG_PAGE, s, e, request);
            return R.error(e.getMessage());
        }
    }

    /**
     * 分页查询未认领超量提醒任务
     * @param pageSize
     * @param pageNo
     * @return
     */
    @GetMapping("/queryOveramount")
    public R queryOveramount(@RequestParam Integer pageSize, @RequestParam Integer pageNo) {
        String s = "";
        try {
            PageRequest pageRequest = PageRequest.of(pageNo - 1, pageSize);
            QueryResults<JgLhjgRwsEntity> results = jgLhjgRwsService.queryOveramount(pageRequest);
            s =JSON.toJSONString(results);
            sysAuditService.saveSuccessAudit("分页查询未认领超量提醒任务成功", Constant.ZFJG_LHJGRWBL, Constant.PT, Constant.ZFJG_PAGE, s, request);
            return R.ok().put("data", results);
        } catch(Exception e) {
            e.printStackTrace();
            sysAuditService.saveFailAudit("分页查询未认领超量提醒任务失败", Constant.ZFJG_MODULE_FEEDBACK, Constant.YZ, Constant.ZFJG_PAGE, s, e, request);
            return R.error(e.getMessage());
        }
    }

    /**
     * 查询所有超时任务的数量
     * @return
     */
    @GetMapping("/queryOvertimeCount")
    public Long queryOvertimeCount() {
        Long count = jgLhjgRwsService.queryOvertimeCount();
        return count;
    }


    /**
     * 查询所有未认领超限任务的数量
     * @return
     */
    @GetMapping("/queryOveramountCount")
    public Long queryOveramountCount() {
        Long count = jgLhjgRwsService.queryOveramountCount();
        return count;

    }
    /**
     * 交换系统返回检查对象List
     */
    @GetMapping("/queryAllRwsMsg")
    public List queryAllJcdx() {
        String s = "";
        try {
            List<JgLhjgRwsEntity> list = jgLhjgRwsService.queryAllRws();
            return list;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
